import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/painting.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart';
import "./res/listData.dart";

void main() {
  runApp(
    MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: const Text('你好flutter1')),
        body: MyApp(),
      ),
    ),
  );
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return Padding(
      padding: const EdgeInsets.all(8),
      child: ListView(
        children: [
          Row(
            children: [
              Text(
                '热搜',
                style: Theme.of(context).textTheme.titleLarge,
              )
            ],
          ),
          Wrap(
            spacing: 3,
            children: [
              Button('女装', onPressed: () {}),
              Button('男装', onPressed: () {}),
              Button('电器', onPressed: () {}),
              Button('手机', onPressed: () {}),
              Button('厨卫', onPressed: () {}),
              Button('生活', onPressed: () {}),
              Button('家具', onPressed: () {}),
              Button('儿童', onPressed: () {}),
              Button('休闲', onPressed: () {}),
              Button('零食', onPressed: () {}),
            ],
          ),
          Row(
            children: [
              Text(
                '历史记录',
                style: Theme.of(context).textTheme.titleLarge,
              )
            ],
          ),
          const Divider(),
          const Column(
            children: [
              ListTile(title: Text('女装')),
              Divider(),
              ListTile(title: Text('男装')),
              Divider(),
              ListTile(title: Text('电器')),
              Divider(),
              ListTile(title: Text('手机')),
            ],
          ),
          const SizedBox(height: 40),
          OutlinedButton.icon(
            onPressed: () {},
            icon: const Icon(Icons.delete),
            label: const Text('清空历史记录'),
          )
        ],
      ),
    );
  }
}

// 自定义按钮
class Button extends StatelessWidget {
  String text;
  void Function()? onPressed;
  Button(this.text, {this.onPressed, super.key});

  @override
  Widget build(BuildContext context) {
    return ElevatedButton(
      onPressed: onPressed,
      style: ButtonStyle(
        foregroundColor: MaterialStateProperty.all(Colors.black),
        backgroundColor: MaterialStateProperty.all(
          const Color.fromARGB(255, 182, 180, 174),
        ),
      ),
      child: Text(text),
    );
  }
}
